home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 9 / litebar.zip / LITEBAR.PRG < prev    next >
Text File  |  1991-08-12  |  31KB  |  854 lines

  1. *-------------------------------------------------------------------------------
  2. *-- Program.....: LITEBAR.PRG 
  3. *-- Programmer..: Ken Mayer
  4. *-- Date........: 7/19/91 
  5. *-- Notes.......: The dBASE Menus are fine to a point, but there are times when
  6. *--               you may need a LOT of menu pads. This program is designed to
  7. *--               allow up to 60 menu items, although you can, if you desire,
  8. *--               setup some options as headers (this will not be chooseable
  9. *--               by the user), and you can set up conditions where an option
  10. *--               may be skipped. This was originally created to handle things
  11. *--               for my fantasy gaming programs, and the idea came from FELIXR
  12. *--               on the AT-BBS. Originally if you chose an item you weren't
  13. *--               allowed to choose it again (this was again based on my gaming
  14. *--               programs), but this was taken out for this version of the
  15. *--               program. The procedures you should need to modify are:
  16. *--                 REFRESH
  17. *--                 LOADARRAY
  18. *--                 DOCHOICE
  19. *--                 VALID
  20. *--               Anything else you may need to modify is noted.
  21. *-- Written for.: dBASE IV, 1.1
  22. *-- Rev. History: 07/17/91 -- Original version, not very flexible, based on
  23. *--                           suggestion from FELXIR (AT-BBS).
  24. *--               07/18/91 -- Version 2 (LITE2.PRG) -- started playing with
  25. *--                           defining the arrays for it.
  26. *--               07/18/91 -- Version 3 (LITE3.PRG) -- got closer, but serious
  27. *--                           problems in MOVECOL and MOVEROW routines. This
  28. *--                           Was uploaded to several programmers on ATBBS.
  29. *--               07/19/91 -- Version 4 (LITE4.PRG) -- after serious thought,
  30. *--                           and some better coding, it works. Added <Home>
  31. *--                           and <End> keys, and remembered to release all
  32. *--                           the public memvars.
  33. *--               07/19/91 -- Version 5 (LITEBAR.PRG) -- modified to be a bit
  34. *--                           more generic than my original program (which was
  35. *--                           designed to be VERY specific to my fantasy gaming
  36. *--                           character generation programs ...) 
  37. *-- Calls.......: Center               (Procedure in PROC.PRG)
  38. *--               ScrnHead             (Procedure in PROC.PRG)
  39. *--               Load_Array           (Procedure in LITEBAR.PRG)
  40. *--               ScrnPnt              (Procedure in LITEBAR.PRG)
  41. *--               MoveCol              (Procedure in LITEBAR.PRG)
  42. *--               MoveRow              (Procedure in LITEBAR.PRG)
  43. *--               HomeEnd              (Procedure in LITEBAR.PRG)
  44. *--               DoChoice             (Procedure in LITEBAR.PRG)
  45. *-- Called by...: Any (after programmer modification)
  46. *-- Usage.......: DO LITEBAR
  47. *-- Example.....: See above
  48. *-- Returns.....: None
  49. *-- Parameters..: None (All internal)
  50. *-------------------------------------------------------------------------------
  51.  
  52. *-- Setup
  53. cTalk   = set("TALK")
  54. set talk off 
  55. cStatus = set("STATUS")
  56. set stat off    && just making sure
  57. cEscape = set("ESCAPE")
  58. set escape off  && for use with INKEY()
  59. cCursor = set("CURSOR")
  60. set cursor off
  61.  
  62. set procedure to proc   && contains a few routines like YESNO ...
  63. clear                   && clear screen completely for this ...
  64. ?scrnhead("rg+/gb","Test Light Bar")
  65.  
  66. public n_LiteRow,n_LiteCol,n_Choice,n_LastCol,n_LastRow  && global memvars
  67.   *-- n_LiteRow = row position
  68.   *-- n_LiteCol = column -- used together to hold real positions
  69.   *-- n_Choice  = user entry (up, down, right, left, <Enter>, <Esc>
  70.   *-- n_LastCol = last column -- entered in REFRESH routine
  71.   *-- n_LastRow = last row    -- ditto
  72.  
  73. nMax = 60                  && max entries
  74. n_Choice = 0               && init user choice
  75.  
  76. public a_LiteBar,a_Pos1,a_Pos2,a_Skip,a_Heading,a_Skill && arrays
  77. declare a_Skill[nMax],a_Pos1[15],a_Pos2[4],a_LiteBar[15,4]
  78. declare a_Skip[15,4],a_Heading[15,4]
  79.   *-- a_Skill[x]      = value we're obtaining from user ... for demo purposes
  80.   *-- a_Pos1[x]       = position of choices on screen ... rows
  81.   *-- a_Pos2[y]       = same ... columns
  82.   *-- a_LiteBar[x,y]  = choices displayed on screen ...
  83.   *-- a_Skip[x,y]     = flag to determine if we should a_Skip an option ...
  84.   *-- a_Heading[x,y]  = if it's a a_Heading, we need to display in specific clrs
  85.  
  86. *--------------------------------------------------------------------------
  87. * START processing here
  88. *--------------------------------------------------------------------------
  89.  
  90. do Load_Array   && procedure below to load values into arrays
  91.  
  92. *-- PROGRAMMER - This must be set for the first LiteBar to be displayed in 
  93. *-- hi-lite colors for scrnpnt routine ...
  94. n_LiteRow = 2     && starting coordinates
  95. n_LiteCol = 1     && ditto
  96. do ScrnPnt        && paint the screen the first time .. the rest is handled
  97.                   && when the cursor is moved ...
  98.  
  99. do while n_Choice # 27    && loop until user presses <Esc>
  100.     
  101.     n_Choice = 0         && default it to 0, just to be safe ....
  102.     n_Choice = inkey(0)
  103.     *-- inkey() returns: 4 = right arrow
  104.     *--                 19 = left arrow
  105.     *--                  5 = up arrow
  106.     *--                 24 = down arrow
  107.     *--                 13 = <Enter>/Carriage Return
  108.     *--                 27 = <Esc>
  109.     *--                  2 = <End>
  110.     *--                 26 = <Home>
  111.     
  112.     do case
  113.         case n_Choice = 4 .or. n_Choice = 19
  114.             do MoveCol
  115.         case n_Choice = 5 .or. n_Choice = 24
  116.             do MoveRow
  117.         case n_Choice = 2 .or. n_Choice = 26
  118.             do HomeEnd
  119.         case n_Choice = 13
  120.             do DoChoice
  121.         case n_Choice = 27    && user pressed ESC
  122.             exit
  123.     endcase
  124. enddo  && loop and main procedure ...
  125.  
  126. *--------------------------------------------------------------------------
  127. *-- CLEANUP
  128. *--------------------------------------------------------------------------
  129. release n_LiteRow,n_LiteCol,n_Choice,n_LastCol,n_LastRow
  130. release a_Pos1,a_Pos2,a_LiteBar,a_Skip,a_Heading
  131. release a_Skill              && for your program you may not need this array
  132. set escape &cEscape          && reset (if needed)
  133. set talk &cTalk
  134. set stat &cStatus
  135. set cursor &cCursor
  136.  
  137. RETURN                       && to calling program
  138. *-- End of Program: LITEBAR.PRG
  139.  
  140. *--------------------------------------------------------------------------
  141. * procedures here
  142. *--------------------------------------------------------------------------
  143.  
  144. PROCEDURE Load_Array
  145. *--------------------------------------------------------------------------
  146. *-- Programmer..: Ken Mayer (Kenmayer)
  147. *-- Date........: 7/17/1991
  148. *-- Notes.......: Used to load the arrays needed for LITEBAR.PRG
  149. *-- Written for.: dBASE IV, 1.1
  150. *-- Rev. History: 7/18/1991 thru 7/19/1991 - minor tweaks here and there
  151. *--               for efficiency's sake.
  152. *-- Calls.......: None
  153. *-- Called by...: LITEBAR.PRG
  154. *-- Usage.......: do Load_Array
  155. *-- Example.....: do Load_Array
  156. *-- Returns.....: None (arrays are PUBLIC memvars)
  157. *-- Parameters..: None
  158. *--------------------------------------------------------------------------
  159.  
  160.     *-- MAY BE REMOVED FROM HERE --*
  161.     nCount = 0                 && initialize "a_Skill" array -- eventually
  162.                                && for my purposes, this info would be gotten
  163.                                && from a database ... this routine can be
  164.                                && removed if you so desire ... (Just this
  165.                                && loop)
  166.     ln_num = int(rand(-1) * 20) + 1
  167.     do while nCount < nMax
  168.         nCount = nCount + 1
  169.         a_Skill[nCount] = int(rand() * 20) + 1   && random number from 1 to 20
  170.     enddo
  171.     *-- TO HERE --*
  172.  
  173.     nCnt1 = 0                && initialize the lightbar array ...
  174.     do while nCnt1 < 15
  175.         nCnt1 = nCnt1 + 1
  176.         nCnt2 = 0
  177.         do while nCnt2 < 4
  178.             nCnt2 = nCnt2 + 1
  179.             a_LiteBar[nCnt1,nCnt2] = space(1)     && init to a single space
  180.                                                   && character in it...
  181.             store .f. to a_Skip[nCnt1,nCnt2]      && init to NO Skip, but change
  182.                                                   && in REFRESH as needed ...
  183.         enddo
  184.     enddo
  185.     
  186.     DO REFRESH   && this is used to setup the litebars ... and can be called
  187.                  && as a separate procedure from anywhere ...
  188.     
  189.     *-- this shouldn't need to be changed ...
  190.     *-- start at row six, allowing room at top of window/screen for a_Headings
  191.     nRow1  =  6
  192.     nRow2  =  7
  193.     nRow3  =  8
  194.     nRow4  =  9
  195.     nRow5  = 10
  196.     nRow6  = 11
  197.     nRow7  = 12
  198.     nRow8  = 13
  199.     nRow9  = 14
  200.     nRow10 = 15
  201.     nRow11 = 16
  202.     nRow12 = 17
  203.     nRow13 = 18
  204.     nRow14 = 19
  205.     nRow15 = 20
  206.     
  207.     *-- set for four columns, up to 20 characters each -- column four should
  208.     *-- be kept down to 15 ... actually all of them should.
  209.     nCol1 = 5
  210.     nCol2 = 25
  211.     nCol3 = 45
  212.     nCol4 = 65
  213.     
  214.     *-- positions -- A_POS1 array is the row
  215.     a_Pos1[1]  = nRow1
  216.     a_Pos1[2]  = nRow2
  217.     a_Pos1[3]  = nRow3
  218.     a_Pos1[4]  = nRow4
  219.     a_Pos1[5]  = nRow5
  220.     a_Pos1[6]  = nRow6
  221.     a_Pos1[7]  = nRow7
  222.     a_Pos1[8]  = nRow8
  223.     a_Pos1[9]  = nRow9
  224.     a_Pos1[10] = nRow10
  225.     a_Pos1[11] = nRow11
  226.     a_Pos1[12] = nRow12
  227.     a_Pos1[13] = nRow13
  228.     a_Pos1[14] = nRow14
  229.     a_Pos1[15] = nRow15
  230.     *-- positions -- A_POS2 array is the column
  231.     a_Pos2[1]  = nCol1
  232.     a_Pos2[2]  = nCol2
  233.     a_Pos2[3]  = nCol3
  234.     a_Pos2[4]  = nCol4
  235.     
  236. RETURN
  237. *-- EoP: Load_Array
  238.  
  239. *--------------------------------------------------------------------------
  240.  
  241. PROCEDURE Refresh 
  242. *--------------------------------------------------------------------------
  243. *-- Programmer..: Ken Mayer (Kenmayer)
  244. *-- Date........: 7/17/1991
  245. *-- Notes.......: Used to define and/or refresh the a_LiteBar array. Very
  246. *--               important if A_SKIP array is being used ...
  247. *-- Written for.: dBASE IV, 1.1
  248. *-- Rev. History: 7/17/1991 -- First version, minor tweaks since ...
  249. *-- Calls.......: None
  250. *-- Called by...: LITEBAR.PRG
  251. *--               DoChoice             (Procedure in LITEBAR.PRG)
  252. *-- Usage.......: do Refresh
  253. *-- Example.....: do Refresh
  254. *-- Returns.....: None (all arrays are public)
  255. *-- Parameters..: None
  256. *--------------------------------------------------------------------------
  257.  
  258.     *-- PROGRAMMER CHANGES --*
  259.  
  260.     *-- Headings should define both A_SKIP and A_HEADING arrays as true for
  261.     *-- those entries, otherwise the program will allow them as "valid"
  262.     *-- choices. If you want to set up conditionals, this is the place to
  263.     *-- do it (such things as:
  264.     *--    IF <condition>
  265.     *--       STORE .T. TO A_SKIP[x,y]
  266.     *--    ELSE
  267.     *--       STORE .F. TO A_SKIP[x,y]
  268.     *--    ENDIF
  269.     *-- this would replace the WHEN in popup BAR definitions ...)
  270.     
  271.     a_LiteBar[1,1] = "HEADING 1"
  272.     store .t. to a_Skip[1,1]     && don't allow as valid choice
  273.     store .t. to a_Heading[1,1]  && for color display
  274.     a_LiteBar[2,1] = "Choice 1: "+ltrim(str(a_Skill[1]))
  275.     a_LiteBar[3,1] = "Choice 2: "+ltrim(str(a_Skill[2]))
  276.     *-- 4,1 = nothing -- blank
  277.     a_LiteBar[5,1] = "HEADING 2"
  278.     store .t. to a_Skip[5,1]
  279.     store .t. to a_Heading[5,1]
  280.     a_LiteBar[6,1] = "Choice 3: "+ltrim(str(a_Skill[3]))
  281.     a_LiteBar[7,1] = "Choice 4: "+ltrim(str(a_Skill[4]))
  282.     *-- column 2
  283.     a_LiteBar[1,2] = "HEADING 3"
  284.     store .t. to a_Skip[1,2]
  285.     store .t. to a_Heading[1,2]
  286.     a_LiteBar[2,2] = "Choice 5: "+ltrim(str(a_Skill[5]))
  287.     a_LiteBar[3,2] = "Choice 6: "+ltrim(str(a_Skill[6]))
  288.     a_LiteBar[4,2] = "Choice 7: "+ltrim(str(a_Skill[7]))
  289.     *-- 5,2 = nothing
  290.     a_LiteBar[6,2] = "HEADING 4"
  291.     store .t. to a_Skip[6,2]
  292.     store .t. to a_Heading[6,2]
  293.     a_LiteBar[7,2] = "Choice 8: "+ltrim(str(a_Skill[8]))
  294.     *-- column 3
  295.     a_LiteBar[1,3] = "HEADING 5"
  296.     store .t. to a_Skip[1,3]
  297.     store .t. to a_Heading[1,3]
  298.     a_LiteBar[2,3] = "Choice  9: "+ltrim(str(a_Skill[9]))
  299.     a_LiteBar[3,3] = "Choice 10: "+ltrim(str(a_Skill[10]))
  300.     a_LiteBar[4,3] = "Choice 11: "+ltrim(str(a_Skill[11]))
  301.     a_LiteBar[5,3] = "Choice 12: "+ltrim(str(a_Skill[12]))
  302.     
  303.     *-- It is VITAL that the last column and last row items be set properly,
  304.     *-- for validation routines when moving the cursor ...
  305.     n_LastCol = 3
  306.     n_LastRow = 7
  307.     
  308.     
  309. RETURN
  310. *-- EoP: Refresh
  311.  
  312. *--------------------------------------------------------------------------
  313.  
  314. PROCEDURE ScrnPnt
  315. *--------------------------------------------------------------------------
  316. *-- Programmer..: Ken Mayer (Kenmayer)
  317. *-- Date........: 07/17/1991
  318. *-- Notes.......: Used to do the initial painting of the screen for the 
  319. *--               lightbar routine.
  320. *-- Written for.: dBASE IV, 1.1
  321. *-- Rev. History: 07/17/1991 -- Original version - called each time the
  322. *--                 lightbar was moved. Bad idea ...
  323. *--               07/19/1991 -- Final version, much more efficiently programmed,
  324. *--                 using arrays to display the screen.
  325. *-- Calls.......: None
  326. *-- Called by...: LITEBAR.PRG
  327. *-- Usage.......: Do ScrnPnt
  328. *-- Example.....: Do ScrnPnt
  329. *-- Returns.....: None
  330. *-- Parameters..: None
  331. *--------------------------------------------------------------------------
  332.     *-- this procedure will probably only be called once - at the beginning
  333.     *-- of the program. There shouldn't be a need to change this ...
  334.     
  335.     nCnt = 0
  336.     do while nCnt < 15
  337.         nCnt = nCnt + 1
  338.         nCnt2 = 0
  339.         do while nCnt2 < 4
  340.             nCnt2 = nCnt2 + 1
  341.             if len(trim(a_LiteBar[nCnt,nCnt2])) > 0
  342.                 if a_Heading[nCnt,nCnt2]
  343.                     @a_Pos1[nCnt],a_Pos2[nCnt2] say a_LiteBar[nCnt,nCnt2];
  344.                         color rg+/gb   && it's a a_Heading
  345.                 else
  346.                     @a_Pos1[nCnt],a_Pos2[nCnt2] say a_LiteBar[nCnt,nCnt2]
  347.                 endif
  348.             endif
  349.         enddo
  350.     enddo
  351.     
  352.     @a_Pos1[n_LiteRow],a_Pos2[n_LiteCol] say a_LiteBar[2,1] color n/g   
  353.         && display first bar higlighted
  354.     
  355.     do center with 23,80,"rg+/r","Press: "+chr(24)+chr(25)+chr(26)+chr(27)+;
  356.         ", <Home>, <End> to move, <Enter> to choose, <Esc> to quit"
  357.     
  358. RETURN
  359. *-- EoP: ScrnPnt
  360.  
  361. *--------------------------------------------------------------------------
  362.  
  363. PROCEDURE MoveRow
  364. *--------------------------------------------------------------------------
  365. *-- Programmer..: Ken Mayer (Kenmayer)
  366. *-- Date........: 07/19/1991
  367. *-- Notes.......: Used when user presses up or down arrow keys. 
  368. *--               This procedure handles up and down movement. It is 
  369. *--               designed to first, redisplay the current litebar area in
  370. *--               "normal" color (default is whatever your screen/window 
  371. *--               NORMAL color is set to). Next, it looks at the keystroke, 
  372. *--               and moves the pointer to the next item. We check
  373. *--               to see if that's valid (using VALID() below), and if it is, 
  374. *--               we are done. If it's not valid, we move in the direction 
  375. *--               (up/down) again, and check for valid, looping until we either 
  376. *--               find a valid option, or, if none of the options in that 
  377. *--               column are valid, we move to the next column. (Tricky, eh?) 
  378. *--               Once we have a valid position, we display it highlighted, 
  379. *--               and return ...
  380. *-- Written for.: dBASE IV, 1.1
  381. *-- Rev. History: 07/17/1991 -- First version, very complex. Had to reprogram
  382. *--                 if a new column was added, and so on.
  383. *--               07/19/1991 -- After much frustration, did a total reprogram
  384. *--                 to what is below. This is quite efficient and doesn't need
  385. *--                 to be modified if rows or columns are added. 
  386. *-- Calls.......: VALID()              (Function in LITEBAR.PRG)
  387. *-- Called by...: LITEBAR.PRG
  388. *--               MoveCol              (Procedure in LITEBAR.PRG)
  389. *-- Usage.......: do MoveRow
  390. *-- Example.....: do MoveRow
  391. *-- Returns.....: None
  392. *-- Parameters..: None
  393. *--------------------------------------------------------------------------
  394.  
  395.     *-- PROGRAMMER -- NO CHANGES NEEDED (in next three procedures) ... --*
  396.     
  397.     *-- redisplay old position ...
  398.     if valid()
  399.         @a_Pos1[n_LiteRow],a_Pos2[n_LiteCol] say a_LiteBar[n_LiteRow,n_LiteCol] 
  400.     endif  && valid()
  401.     
  402.     do case
  403.         *-- uparrow first
  404.         case n_Choice = 5 
  405.             
  406.             if n_LiteRow = 1               && if first row
  407.                 n_LiteRow = n_LastRow       && wrap it around ...
  408.             else
  409.                 n_LiteRow = n_LiteRow - 1   && decrement (move up to next row)
  410.             endif
  411.             nCount = 1                     && set counter to 1
  412.             do while .not. Valid()         && function below to determine if 
  413.                                            &&   a_LiteBar is valid
  414.                 nCount = nCount + 1         && if we're here, we're moving again
  415.                 if nCount = n_LastRow       && we've wrapped around
  416.                     n_Choice = 4             && stick a right arrow in here ...
  417.                     do MoveCol               && procedure to move cursor by col!
  418.                     exit                     && we're done here ...
  419.                 endif                       && nCount = n_LastRow
  420.                 if n_LiteRow = 1            && check for first row
  421.                     n_LiteRow = n_LastRow    && wrap around
  422.                 else
  423.                     n_LiteRow = n_LiteRow - 1  && decrement (move to next)
  424.                 endif
  425.             enddo
  426.             
  427.         *-- down arrow next
  428.         case n_Choice = 24
  429.     
  430.             if n_LiteRow = n_LastRow       && if last row
  431.                 n_LiteRow = 1               && wrap it around ...
  432.             else
  433.                 n_LiteRow = n_LiteRow + 1   && increment (move to next row)
  434.             endif
  435.             nCount = 1                     && set counter to 1
  436.             do while .not. Valid()         && function below to determine if 
  437.                                            && a_LiteBar is valid
  438.                 nCount = nCount + 1         && if we're here, we're moving again
  439.                 if nCount = n_LastRow       && we've wrapped around
  440.                     n_Choice = 19            && stick a left arrow in here ...
  441.                     do MoveCol               && procedure to move cursor by col!
  442.                     exit                     && we're done here ...
  443.                 endif                       && nCount = n_LastRow
  444.                 if n_LiteRow = n_LastRow    && check for last row
  445.                     n_LiteRow = 1            && wrap around
  446.                 else
  447.                     n_LiteRow = n_LiteRow + 1  && increment (move to next)
  448.                 endif
  449.             enddo
  450.             
  451.     endcase
  452.     
  453.     *-- clean out current row, just to be safe ...
  454.     @a_Pos1[n_LiteRow],a_Pos2[n_LiteCol] clear to ;
  455.                        a_Pos1[n_LiteRow],a_Pos2[n_LiteCol]+19
  456.     *-- redisplay but highlighted this time ...
  457.     @a_Pos1[n_LiteRow],a_Pos2[n_LiteCol] say ;
  458.                        a_LiteBar[n_LiteRow,n_LiteCol] color n/g
  459.         
  460. RETURN
  461. *-- EoP: MoveRow
  462.  
  463. *--------------------------------------------------------------------------
  464.  
  465. PROCEDURE MoveCol
  466. *--------------------------------------------------------------------------
  467. *-- Programmer..: Ken Mayer (Kenmayer)
  468. *-- Date........: 07/19/1991
  469. *-- Notes.......: See MoveRow for details -- it works the same, except
  470. *--               left/right, instead of up/down.
  471. *-- Written for.: dBASE IV, 1.1
  472. *-- Rev. History: See MoveRow for details
  473. *-- Calls.......: VALID()              (Function in LITEBAR.PRG)
  474. *-- Called by...: LITEBAR.PRG
  475. *--               MoveRow              (Procedure in LITEBAR.PRG)
  476. *--               HomeEnd              (Procedure in LITEBAR.PRG)
  477. *-- Usage.......: Do MoveCol
  478. *-- Example.....: Do MoveCol
  479. *-- Returns.....: None
  480. *-- Parameters..: None
  481. *--------------------------------------------------------------------------
  482.  
  483.     if valid()
  484.         @a_Pos1[n_LiteRow],a_Pos2[n_LiteCol] say a_LiteBar[n_LiteRow,n_LiteCol] 
  485.     endif && valid()
  486.     
  487.     do case
  488.     
  489.         case n_Choice = 4
  490.         ** right arrow
  491.             if n_LiteCol = n_LastCol       && if last column
  492.                 n_LiteCol = 1               && wrap it around ...
  493.             else
  494.                 n_LiteCol = n_LiteCol + 1   && increment (move to next column)
  495.             endif
  496.             nCount = 1                     && set counter to 1
  497.             do while .not. Valid()         && function below to determine if 
  498.                                            &&   a_LiteBar is valid
  499.                 nCount = nCount + 1         && if we're here, we're moving again
  500.                 if nCount = n_LastCol       && we've wrapped around
  501.                     n_Choice = 24            && stick a down arrow in here ...
  502.                     do MoveRow               && procedure to move cursor by rows!
  503.                     exit                     && we're done here ...
  504.                 endif                       && nCount = n_LastCol
  505.                 if n_LiteCol = n_LastCol    && check for last column
  506.                     n_LiteCol = 1            && wrap around
  507.                 else
  508.                     n_LiteCol = n_LiteCol + 1  && increment (move to next)
  509.                 endif
  510.             enddo
  511.             
  512.         *-- left arrow next
  513.         case n_Choice = 19 
  514.     
  515.             if n_LiteCol = 1               && if FIRST column
  516.                 n_LiteCol = n_LastCol       && wrap it around ...
  517.             else
  518.                 n_LiteCol = n_LiteCol - 1   && decrement (move to next column)
  519.             endif
  520.             nCount = 1                     && set counter to 1
  521.             do while .not. Valid()         && function below to determine if 
  522.                                            &&   a_LiteBar is valid ...
  523.                 nCount = nCount + 1         && if we're here, we're moving again
  524.                 if nCount = n_LastCol       && we've wrapped around
  525.                     n_Choice = 5             && stick an up arrow in here ...
  526.                     do MoveRow               && procedure to move cursor by rows!
  527.                     exit                     && we're done here ...
  528.                 endif                       && nCount = n_LastCol
  529.                 if n_LiteCol = 1            && check for last column
  530.                     n_LiteCol = n_LastCol    && wrap around
  531.                 else
  532.                     n_LiteCol = n_LiteCol - 1  && decrement (move to next)
  533.                 endif
  534.             enddo
  535.     endcase
  536.     
  537.     *-- clean out current row, just to be safe ...
  538.     @a_Pos1[n_LiteRow],a_Pos2[n_LiteCol] clear to ;
  539.                 a_Pos1[n_LiteRow],a_Pos2[n_LiteCol]+19
  540.     @a_Pos1[n_LiteRow],a_Pos2[n_LiteCol] say ;
  541.                 a_LiteBar[n_LiteRow,n_LiteCol] color n/g
  542.     
  543. RETURN
  544. *-- EoP: MoveCol
  545.  
  546. *--------------------------------------------------------------------------
  547.  
  548. PROCEDURE HomeEnd
  549. *--------------------------------------------------------------------------
  550. *-- Programmer..: Ken Mayer (Kenmayer)
  551. *-- Date........: 07/19/1991
  552. *-- Notes.......: Very much the same type of logic as MoveRow and MoveCol, 
  553. *--               but cursor is moved to first position (<Home>) or last 
  554. *--               (<End>) and validation is checked in those columns ...
  555. *-- Written for.: dBASE IV, 1.1
  556. *-- Rev. History: none
  557. *-- Calls.......: MoveCol              (Procedure in LITEBAR.PRG)
  558. *-- Called by...: LITEBAR.PRG
  559. *-- Usage.......: do HomeEnd
  560. *-- Example.....: do HomeEnd
  561. *-- Returns.....: None
  562. *-- Parameters..: None
  563. *--------------------------------------------------------------------------
  564.     
  565.     if valid()
  566.         @a_Pos1[n_LiteRow],a_Pos2[n_LiteCol] say a_LiteBar[n_LiteRow,n_LiteCol] 
  567.     endif  && valid()
  568.     
  569.     do case
  570.         *-- For HOME, we need to go to first position, and move down the column,
  571.         *-- as if we were doing the routine in MOVEROW ... for END we do the
  572.         *-- same, but go to last position, and work UP the column, looking for 
  573.         *-- valid ...
  574.         
  575.         case n_Choice = 26
  576.         *-- <Home> key
  577.             n_LiteCol = 1                  && move pointer to "Home" position
  578.             n_LiteRow = 1
  579.             
  580.             nCount = 1                     && set counter to 1
  581.             do while .not. Valid()         && function below to determine if 
  582.                                            &&   a_LiteBar is valid
  583.                 nCount = nCount + 1         && if we're here, we're moving again
  584.                 if nCount = n_LastRow       && we've wrapped around
  585.                     n_Choice = 4             && stick a right arrow in here ...
  586.                     do MoveCol               && procedure to move cursor by rows!
  587.                     exit                     && we're done here ...
  588.                 endif                       && nCount = n_LastRow
  589.                 if n_LiteRow = n_LastRow    && check for last column
  590.                     n_LiteRow = 1            && wrap around
  591.                 else
  592.                     n_LiteRow = n_LiteRow + 1  && increment (move to next)
  593.                 endif
  594.             enddo
  595.         
  596.         case n_Choice = 2
  597.             *-- <End> key
  598.             n_LiteRow = n_LastRow          && move cursor to last item
  599.             n_LiteCol = n_LastCol
  600.             
  601.             nCount = 1                     && set counter to 1
  602.             do while .not. Valid()         && function below to determine if 
  603.                                            &&   a_LiteBar is valid
  604.                 nCount = nCount + 1         && if we're here, we're moving again
  605.                 if nCount = n_LastRow       && we've wrapped around
  606.                     n_Choice = 19            && stick a left arrow in here ...
  607.                     do MoveCol               && procedure to move cursor by col
  608.                     exit                     && we're done here ...
  609.                 endif                       && nCount = n_LastRow
  610.                 if n_LiteRow = 1            && check for first row
  611.                     n_LiteRow = n_LastRow    && wrap around
  612.                 else
  613.                     n_LiteRow = n_LiteRow - 1  && increment (move to next)
  614.                 endif
  615.             enddo
  616.             
  617.     endcase
  618.     
  619.     *-- clean out current row, just to be safe ...
  620.     @a_Pos1[n_LiteRow],a_Pos2[n_LiteCol] clear to ;
  621.                 a_Pos1[n_LiteRow],a_Pos2[n_LiteCol]+19
  622.     @a_Pos1[n_LiteRow],a_Pos2[n_LiteCol] say ;
  623.                 a_LiteBar[n_LiteRow,n_LiteCol] color n/g
  624.         && display in hilight colors ...
  625.  
  626. RETURN 
  627. *-- EoP: HomeEnd
  628.  
  629. *--------------------------------------------------------------------------
  630.  
  631. PROCEDURE DoChoice
  632. *--------------------------------------------------------------------------
  633. *-- Programmer..: Ken Mayer (Kenmayer)
  634. *-- Date........: 07/19/1991
  635. *-- Notes.......: This is where we go when the user has pressed <Enter>. 
  636. *--               It means they want to choose the highlighted option. 
  637. *--               The current structure below looks at the column, and then 
  638. *--               the row we are pointing to to decide what to do. Such 
  639. *--               options as  "DO <program>"  can be placed in the approprate
  640. *--               cases ... if a header is in row1 column1, leave the case 
  641. *--               blank, if you want to execute a program, or do something
  642. *--               else (assign a value ... whatever), put that command in 
  643. *--               the appropriate case. You may need to look at your REFRESH 
  644. *--               procedure definitions to set this part properly ...
  645. *-- Written for.: dBASE IV, 1.1
  646. *-- Rev. History: None
  647. *-- Calls.......: Center               (Procedure in PROC.PRG)
  648. *--               Refresh              (Procedure in LITEBAR.PRG)
  649. *-- Called by...: LITEBAR.PRG
  650. *-- Usage.......: Do DoChoice
  651. *-- Example.....: Do DoChoice
  652. *-- Returns.....: None
  653. *-- Parameters..: None
  654. *--------------------------------------------------------------------------
  655.     
  656.     *-- PROGRAMMER CHANGES --*
  657.     
  658.     *-- can this be done more efficiently? I can't think of a better
  659.     *-- way ... >sigh<.
  660.     
  661.     do case
  662.         case n_LiteCol = 1
  663.             do case
  664.                 case n_LiteRow = 1
  665.                 
  666.                 case n_LiteRow = 2
  667.                     
  668.                 case n_LiteRow = 3
  669.                     
  670.                 case n_LiteRow = 4
  671.                 
  672.                 case n_LiteRow = 5
  673.                 
  674.                 case n_LiteRow = 6
  675.                     
  676.                 case n_LiteRow = 7
  677.                     
  678.                 case n_LiteRow = 8
  679.                 
  680.                 case n_LiteRow = 9
  681.                 
  682.                 case n_LiteRow = 10
  683.                 
  684.                 case n_LiteRow = 11
  685.                 
  686.                 case n_LiteRow = 12
  687.                 
  688.                 case n_LiteRow = 13
  689.                 
  690.                 case n_LiteRow = 14
  691.                 
  692.                 case n_LiteRow = 15
  693.                 
  694.             endcase
  695.         case n_LiteCol = 2
  696.             do case
  697.                 case n_LiteRow = 1
  698.                 
  699.                 case n_LiteRow = 2
  700.                     
  701.                 case n_LiteRow = 3
  702.                     
  703.                 case n_LiteRow = 4
  704.                     
  705.                 case n_LiteRow = 5
  706.                 
  707.                 case n_LiteRow = 6
  708.                 
  709.                 case n_LiteRow = 7
  710.                     
  711.                 case n_LiteRow = 8
  712.                 
  713.                 case n_LiteRow = 9
  714.                 
  715.                 case n_LiteRow = 10
  716.                 
  717.                 case n_LiteRow = 11
  718.                 
  719.                 case n_LiteRow = 12
  720.                 
  721.                 case n_LiteRow = 13
  722.                 
  723.                 case n_LiteRow = 14
  724.                 
  725.                 case n_LiteRow = 15
  726.                 
  727.             endcase
  728.         case n_LiteCol = 3
  729.             do case
  730.                 case n_LiteRow = 1
  731.                 
  732.                 case n_LiteRow = 2
  733.                     
  734.                 case n_LiteRow = 3
  735.                     
  736.                 case n_LiteRow = 4
  737.                     
  738.                 case n_LiteRow = 5
  739.                     
  740.                 case n_LiteRow = 6
  741.                 
  742.                 case n_LiteRow = 7
  743.                 
  744.                 case n_LiteRow = 8
  745.                 
  746.                 case n_LiteRow = 9
  747.                 
  748.                 case n_LiteRow = 10
  749.                 
  750.                 case n_LiteRow = 11
  751.                 
  752.                 case n_LiteRow = 12
  753.                 
  754.                 case n_LiteRow = 13
  755.                 
  756.                 case n_LiteRow = 14
  757.                 
  758.                 case n_LiteRow = 15
  759.                 
  760.             endcase
  761.         
  762.         case n_LiteCol = 4
  763.             do case
  764.                 case n_LiteRow = 1
  765.             
  766.                 case n_LiteRow = 2
  767.                 
  768.                 case n_LiteRow = 3
  769.                 
  770.                 case n_LiteRow = 4
  771.                 
  772.                 case n_LiteRow = 5
  773.                 
  774.                 case n_LiteRow = 6
  775.                 
  776.                 case n_LiteRow = 7
  777.                 
  778.                 case n_LiteRow = 8
  779.                 
  780.                 case n_LiteRow = 9
  781.                 
  782.                 case n_LiteRow = 10
  783.                 
  784.                 case n_LiteRow = 11
  785.                 
  786.                 case n_LiteRow = 12
  787.                 
  788.                 case n_LiteRow = 13
  789.                 
  790.                 case n_LiteRow = 14
  791.                 
  792.                 case n_LiteRow = 15
  793.                 
  794.             endcase
  795.     endcase
  796.     
  797.     *-- PROGRAMMER CHANGE --* these two lines are here for demo only ...
  798.     @22,0 clear to 22,79  && clear out old one
  799.     do center with 22,80,"","You chose to do item "+a_LiteBar[n_LiteRow,n_LiteCol]
  800.     
  801.     *-- Next two commands are necessary if you are changing some values.
  802.     *-- with this demo, they could be removed ... If you change the
  803.     *-- a_LiteBar option after choosing it, then these are vital. They
  804.     *-- don't slow the program down appreciably, and can be left alone.
  805.     do refresh   && if you have set some A_SKIP options this is vital
  806.     
  807.     *-- clean out current row, just to be safe ...
  808.     @a_Pos1[n_LiteRow],a_Pos2[n_LiteCol] clear to ;
  809.                 a_Pos1[n_LiteRow],a_Pos2[n_LiteCol]+19
  810.     
  811.     *-- redisplay highlighted (it is the current choice ...) -- important
  812.     *-- if the a_LiteBar definition has changed ...
  813.     @a_Pos1[n_LiteRow],a_Pos2[n_LiteCol] say ;
  814.                 a_LiteBar[n_LiteRow,n_LiteCol] color n/g
  815.  
  816. RETURN
  817. *-- EoP: DoChoice
  818.  
  819. *--------------------------------------------------------------------------
  820.  
  821. FUNCTION Valid
  822. *--------------------------------------------------------------------------
  823. *-- Programmer..: Ken Mayer (Kenmayer)
  824. *-- Date........: 07/18/1991
  825. *-- Notes.......: Used to determine if 'current' a_LiteBar option is a valid
  826. *--               one.
  827. *-- Written for.: dBASE IV, 1.1.
  828. *-- Rev. History: None
  829. *-- Calls.......: None
  830. *-- Called by...: MoveRow              (Procedure in LITEBAR.PRG)
  831. *--               MoveCol              (Procedure in LITEBAR.PRG)
  832. *--               HomeEnd              (Procedure in LITEBAR.PRG)
  833. *-- Usage.......: valid()
  834. *-- Example.....: Do while .not. valid()
  835. *--                  && statements to move cursor and such...
  836. *--               Enddo
  837. *-- Returns.....: .t./.f.  -- logical
  838. *-- Parameters..: None
  839. *--------------------------------------------------------------------------
  840.  
  841.     if len(trim(a_LiteBar[n_LiteRow,n_LiteCol])) > 0 .and. .not. ;
  842.            a_Skip[n_LiteRow,n_LiteCol]
  843.         store .t. to lValid
  844.     else
  845.         store .f. to lValid
  846.     endif
  847.  
  848. RETURN lValid
  849. *-- EoF: Valid
  850.  
  851. *--------------------------------------------------------------------------
  852. * End of Program: LITEBAR.PRG
  853. *--------------------------------------------------------------------------
  854.